package ua.eug.airv1.map;

import ua.eug.airv1.ImageProvider;
import ua.eug.airv1.plane.Plane;
import ua.eug.airv1.utils.Config;
import ua.eug.airv1.weapon.ExplosionPool;
import ua.eug.airv1.weapon.IWeapon;
import ua.eug.airv1.weapon.ZWeapon;

import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.scenes.scene2d.Actor;

public class Tile extends Actor {
	private final float width = Config.TileWidth;
	private final float heigth = Config.TileHeight;
	
	public static Tile ZTile = new Tile();
	
	private int type[] = {0,0,0};
	public TilePos pos;
	public Plane plane;
	public Boolean disabled = false;
	private Boolean isExplode = false;
	private Boolean fogOfWar = false;
	
	private IWeapon groundWeapon = ZWeapon.Nobody;
	private IWeapon airWeapon = ZWeapon.Nobody;
	
	public Tile (int type[]) {
		super();
		this.type = type;
	}

	public Tile () {
		super();
	}

	public void setExplode(Boolean ex) {
		if (ex && ! isExplode) {
			isExplode = true;
			ExplosionPool.getInstance().newExplosion(this);
		} else {
			isExplode = false;
		}
	}
	
	@Override
    public void draw(Batch batch, float alpha){
		batch.draw(ImageProvider.Lands[type[0]],  getX(), getY());
		batch.draw(ImageProvider.Lands[type[1]],  getX()+Config.TileWidth/2, getY());
		batch.draw(ImageProvider.Lands[type[2]],  getX()+Config.TileWidth/4, getY()+Config.TileHeight/2);

//		if (fogOfWar)
//			batch.draw(ImageProvider.FogOfWar,	getX(), getY());
    }
	
	//---- distribute damage
	public void killAir(IWeapon killer) {
		airWeapon.doAirDamage(killer);
	}
	public void killGround(IWeapon killer) {
		groundWeapon.doGroundDamage(killer);
	}
	
	//---- Getter/setter
	public IWeapon getGroundWeapon() {
		return groundWeapon;
	}
	public IWeapon getAirWeapon() {
		return airWeapon;
	}
	public void setAirWeapon(IWeapon air) {
		airWeapon = air;
	}
	public void setGroundWeapon(IWeapon gr) {
		groundWeapon = gr;
	}
	public Boolean isFogOfWar() {
		return fogOfWar;
	}
	public void setFogOfWar(Boolean fogOfWar) {
		this.fogOfWar = fogOfWar;
	}

}
